home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / bin / h2ph.z / h2ph
Encoding:
Text File  |  1998-10-28  |  16.1 KB  |  597 lines

  1. #!/usr/freeware/bin/perl
  2.     eval 'exec /usr/freeware/bin/perl -S $0 ${1+"$@"}'
  3.     if $running_under_some_shell;
  4.  
  5. use Config;
  6. use File::Path qw(mkpath);
  7. use Getopt::Std;
  8.  
  9. getopts('Dd:rlhaQ');
  10. die "-r and -a options are mutually exclusive\n" if ($opt_r and $opt_a);
  11. @inc_dirs = inc_dirs() if $opt_a;
  12.  
  13. my $Exit = 0;
  14.  
  15. my $Dest_dir = $opt_d || $Config{installsitearch};
  16. die "Destination directory $Dest_dir doesn't exist or isn't a directory\n"
  17.     unless -d $Dest_dir;
  18.  
  19. @isatype = split(' ',<<END);
  20.     char    uchar    u_char
  21.     short    ushort    u_short
  22.     int    uint    u_int
  23.     long    ulong    u_long
  24.     FILE    key_t    caddr_t
  25. END
  26.  
  27. @isatype{@isatype} = (1) x @isatype;
  28. $inif = 0;
  29.  
  30. @ARGV = ('-') unless @ARGV;
  31.  
  32. while (defined ($file = next_file())) {
  33.     if (-l $file and -d $file) {
  34.         link_if_possible($file) if ($opt_l);
  35.         next;
  36.     }
  37.  
  38.     # Recover from header files with unbalanced cpp directives
  39.     $t = '';
  40.     $tab = 0;
  41.  
  42.     # $eval_index goes into ``#line'' directives, to help locate syntax errors:
  43.     $eval_index = 1;
  44.  
  45.     if ($file eq '-') {
  46.     open(IN, "-");
  47.     open(OUT, ">-");
  48.     } else {
  49.     ($outfile = $file) =~ s/\.h$/.ph/ || next;
  50.     print "$file -> $outfile\n" unless $opt_Q;
  51.     if ($file =~ m|^(.*)/|) {
  52.         $dir = $1;
  53.         mkpath "$Dest_dir/$dir";
  54.     }
  55.  
  56.     if ($opt_a) { # automagic mode:  locate header file in @inc_dirs
  57.         foreach (@inc_dirs) {
  58.         chdir $_;
  59.         last if -f $file;
  60.         }
  61.     }
  62.  
  63.     open(IN,"$file") || (($Exit = 1),(warn "Can't open $file: $!\n"),next);
  64.     open(OUT,">$Dest_dir/$outfile") || die "Can't create $outfile: $!\n";
  65.     }
  66.     while (<IN>) {
  67.     chop;
  68.     while (/\\$/) {
  69.         chop;
  70.         $_ .= <IN>;
  71.         chop;
  72.     }
  73.     print OUT "# $_\n" if $opt_D;
  74.     if (s:/\*:\200:g) {
  75.         s:\*/:\201:g;
  76.         s/\200[^\201]*\201//g;    # delete single line comments
  77.         if (s/\200.*//) {        # begin multi-line comment?
  78.         $_ .= '/*';
  79.         $_ .= <IN>;
  80.         redo;
  81.         }
  82.     }
  83.     if (s/^\s*\#\s*//) {
  84.         if (s/^define\s+(\w+)//) {
  85.         $name = $1;
  86.         $new = '';
  87.         s/\s+$//;
  88.         if (s/^\(([\w,\s]*)\)//) {
  89.             $args = $1;
  90.                     my $proto = '() ';
  91.             if ($args ne '') {
  92.                         $proto = '';
  93.             foreach $arg (split(/,\s*/,$args)) {
  94.                 $arg =~ s/^\s*([^\s].*[^\s])\s*$/$1/;
  95.                 $curargs{$arg} = 1;
  96.             }
  97.             $args =~ s/\b(\w)/\$$1/g;
  98.             $args = "local($args) = \@_;\n$t    ";
  99.             }
  100.             s/^\s+//;
  101.             expr();
  102.             $new =~ s/(["\\])/\\$1/g;       #"]);
  103.             $new = reindent($new);
  104.             $args = reindent($args);
  105.             if ($t ne '') {
  106.             $new =~ s/(['\\])/\\$1/g;   #']);
  107.             if ($opt_h) {
  108.                 print OUT $t,
  109.                             "eval \"\\n#line $eval_index $outfile\\n\" . 'sub $name $proto\{\n$t    ${args}eval q($new);\n$t}' unless defined(\&$name);\n";
  110.                             $eval_index++;
  111.             } else {
  112.                 print OUT $t,
  113.                             "eval 'sub $name $proto\{\n$t    ${args}eval q($new);\n$t}' unless defined(\&$name);\n";
  114.             }
  115.             } else {
  116.                       print OUT "unless(defined(\&$name)) {\n    sub $name $proto\{\n\t${args}eval q($new);\n    }\n}\n";
  117.             }
  118.             %curargs = ();
  119.         } else {
  120.             s/^\s+//;
  121.             expr();
  122.             $new = 1 if $new eq '';
  123.             $new = reindent($new);
  124.             $args = reindent($args);
  125.             if ($t ne '') {
  126.             $new =~ s/(['\\])/\\$1/g;        #']);
  127.             if ($opt_h) {
  128.                 print OUT $t,"eval \"\\n#line $eval_index $outfile\\n\" . 'sub $name () {",$new,";}' unless defined(\&$name);\n";
  129.                 $eval_index++;
  130.             } else {
  131.                 print OUT $t,"eval 'sub $name () {",$new,";}' unless defined(\&$name);\n";
  132.             }
  133.             } else {
  134.                       print OUT $t,"unless(defined(\&$name)) {\n    sub $name () {\t",$new,";}\n}\n";
  135.             }
  136.         }
  137.         } elsif (/^(include|import)\s*[<"](.*)[>"]/) {
  138.         ($incl = $2) =~ s/\.h$/.ph/;
  139.         print OUT $t,"require '$incl';\n";
  140.         } elsif(/^include_next\s*[<"](.*)[>"]/) {
  141.         ($incl = $1) =~ s/\.h$/.ph/;
  142.         print OUT ($t,
  143.                "eval {\n");
  144.                 $tab += 4;
  145.                 $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  146.         print OUT ($t,
  147.                "my(\%INCD) = map { \$INC{\$_} => 1 } ",
  148.                "(grep { \$_ eq \"$incl\" } keys(\%INC));\n");
  149.         print OUT ($t,
  150.                "my(\@REM) = map { \"\$_/$incl\" } ",
  151.                "(grep { not exists(\$INCD{\"\$_/$incl\"})",
  152.                "and -f \"\$_/$incl\" } \@INC);\n");
  153.         print OUT ($t,
  154.                "require \"\$REM[0]\" if \@REM;\n");
  155.                 $tab -= 4;
  156.                 $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  157.                 print OUT ($t,
  158.                "};\n");
  159.         print OUT ($t,
  160.                "warn(\$\@) if \$\@;\n");
  161.         } elsif (/^ifdef\s+(\w+)/) {
  162.         print OUT $t,"if(defined(&$1)) {\n";
  163.         $tab += 4;
  164.         $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  165.         } elsif (/^ifndef\s+(\w+)/) {
  166.         print OUT $t,"unless(defined(&$1)) {\n";
  167.         $tab += 4;
  168.         $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  169.         } elsif (s/^if\s+//) {
  170.         $new = '';
  171.         $inif = 1;
  172.         expr();
  173.         $inif = 0;
  174.         print OUT $t,"if($new) {\n";
  175.         $tab += 4;
  176.         $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  177.         } elsif (s/^elif\s+//) {
  178.         $new = '';
  179.         $inif = 1;
  180.         expr();
  181.         $inif = 0;
  182.         $tab -= 4;
  183.         $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  184.         print OUT $t,"}\n elsif($new) {\n";
  185.         $tab += 4;
  186.         $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  187.         } elsif (/^else/) {
  188.         $tab -= 4;
  189.         $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  190.         print OUT $t,"} else {\n";
  191.         $tab += 4;
  192.         $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  193.         } elsif (/^endif/) {
  194.         $tab -= 4;
  195.         $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  196.         print OUT $t,"}\n";
  197.         } elsif(/^undef\s+(\w+)/) {
  198.         print OUT $t, "undef(&$1) if defined(&$1);\n";
  199.         } elsif(/^error\s+"?([^"\n]*)/) {
  200.         print OUT $t, "die(\"$1\");\n";
  201.         } elsif(/^warning\s+"?([^"\n]*)/) {
  202.         print OUT $t, "warn(\"$1\");\n";
  203.         } elsif(/^ident\s+(.*)/) {
  204.         print OUT $t, "# $1\n";
  205.         }
  206.      } elsif(/^\s*(typedef\s*)?enum\s*(\s+[a-zA-Z_]\w*\s*)?\{/) {
  207.         until(/\}.*?;/) {
  208.         chomp($next = <IN>);
  209.         $_ .= $next;
  210.         print OUT "# $next\n" if $opt_D;
  211.         }
  212.         s@/\*.*?\*/@@g;
  213.         s/\s+/ /g;
  214.         /^\s?(typedef\s?)?enum\s?([a-zA-Z_]\w*)?\s?\{(.*)\}\s?([a-zA-Z_]\w*)?\s?;/;
  215.         ($enum_subs = $3) =~ s/\s//g;
  216.         @enum_subs = split(/,/, $enum_subs);
  217.         $enum_val = -1;
  218.         for $enum (@enum_subs) {
  219.         ($enum_name, $enum_value) = $enum =~ /^([a-zA-Z_]\w*)(=.+)?$/;
  220.         $enum_value =~ s/^=//;
  221.         $enum_val = (length($enum_value) ? $enum_value : $enum_val + 1);
  222.         if ($opt_h) {
  223.             print OUT ($t,
  224.                    "eval(\"\\n#line $eval_index $outfile\\n",
  225.                    "sub $enum_name () \{ $enum_val; \}\") ",
  226.                    "unless defined(\&$enum_name);\n");
  227.             ++ $eval_index;
  228.         } else {
  229.             print OUT ($t,
  230.                    "eval(\"sub $enum_name () \{ $enum_val; \}\") ",
  231.                    "unless defined(\&$enum_name);\n");
  232.         }
  233.         }
  234.     }
  235.     }
  236.     print OUT "1;\n";
  237.  
  238.     $is_converted{$file} = 1;
  239.     queue_includes_from($file) if ($opt_a);
  240. }
  241.  
  242. exit $Exit;
  243.  
  244. sub reindent($) {
  245.     my($text) = shift;
  246.     $text =~ s/\n/\n    /g;
  247.     $text =~ s/        /\t/g;
  248.     $text;
  249. }
  250.  
  251. sub expr {
  252.     if(keys(%curargs)) {
  253.     my($joined_args) = join('|', keys(%curargs));
  254.     }
  255.     while ($_ ne '') {
  256.     s/^\&\&// && do { $new .= " &&"; next;}; # handle && operator
  257.     s/^\&([\(a-z\)]+)/$1/i;    # hack for things that take the address of
  258.     s/^(\s+)//        && do {$new .= ' '; next;};
  259.     s/^(0X[0-9A-F]+)[UL]*//i    && do {$new .= lc($1); next;};
  260.     s/^(-?\d+\.\d+E[-+]\d+)F?//i    && do {$new .= $1; next;};
  261.     s/^(\d+)\s*[LU]*//i    && do {$new .= $1; next;};
  262.     s/^("(\\"|[^"])*")//    && do {$new .= $1; next;};
  263.     s/^'((\\"|[^"])*)'//    && do {
  264.         if ($curargs{$1}) {
  265.         $new .= "ord('\$$1')";
  266.         } else {
  267.         $new .= "ord('$1')";
  268.         }
  269.         next;
  270.     };
  271.         # replace "sizeof(foo)" with "{foo}"
  272.         # also, remove * (C dereference operator) to avoid perl syntax
  273.         # problems.  Where the %sizeof array comes from is anyone's
  274.         # guess (c2ph?), but this at least avoids fatal syntax errors.
  275.         # Behavior is undefined if sizeof() delimiters are unbalanced.
  276.         # This code was modified to able to handle constructs like this:
  277.         #   sizeof(*(p)), which appear in the HP-UX 10.01 header files.
  278.         s/^sizeof\s*\(// && do {
  279.             $new .= '$sizeof';
  280.             my $lvl = 1;  # already saw one open paren
  281.             # tack { on the front, and skip it in the loop
  282.             $_ = "{" . "$_";
  283.             my $index = 1;
  284.             # find balanced closing paren
  285.             while ($index <= length($_) && $lvl > 0) {
  286.                 $lvl++ if substr($_, $index, 1) eq "(";
  287.                 $lvl-- if substr($_, $index, 1) eq ")";
  288.                 $index++;
  289.             }
  290.             # tack } on the end, replacing )
  291.             substr($_, $index - 1, 1) = "}";
  292.             # remove pesky * operators within the sizeof argument
  293.             substr($_, 0, $index - 1) =~ s/\*//g;
  294.             next;
  295.         };
  296.     # Eliminate typedefs
  297.     /\(([\w\s]+)[\*\s]*\)\s*[\w\(]/ && do {
  298.         foreach (split /\s+/, $1) {  # Make sure all the words are types,
  299.         last unless ($isatype{$_} or $_ eq 'struct');
  300.         }
  301.         s/\([\w\s]+[\*\s]*\)// && next;      # then eliminate them.
  302.     };
  303.     # struct/union member, including arrays:
  304.     s/^([_A-Z]\w*(\[[^\]]+\])?((\.|->)[_A-Z]\w*(\[[^\]]+\])?)+)//i && do {
  305.         $id = $1;
  306.         $id =~ s/(\.|(->))([^\.\-]*)/->\{$3\}/g;
  307.         $id =~ s/\b([^\$])($joined_args)/$1\$$2/g if length($joined_args);
  308.         while($id =~ /\[\s*([^\$\&\d\]]+)\]/) {
  309.         my($index) = $1;
  310.         $index =~ s/\s//g;
  311.         if(exists($curargs{$index})) {
  312.             $index = "\$$index";
  313.         } else {
  314.             $index = "&$index";
  315.         }
  316.         $id =~ s/\[\s*([^\$\&\d\]]+)\]/[$index]/;
  317.         }
  318.         $new .= " (\$$id)";
  319.     };
  320.     s/^([_a-zA-Z]\w*)//    && do {
  321.         $id = $1;
  322.         if ($id eq 'struct') {
  323.         s/^\s+(\w+)//;
  324.         $id .= ' ' . $1;
  325.         $isatype{$id} = 1;
  326.         } elsif ($id =~ /^((un)?signed)|(long)|(short)$/) {
  327.         while (s/^\s+(\w+)//) { $id .= ' ' . $1; }
  328.         $isatype{$id} = 1;
  329.         }
  330.         if ($curargs{$id}) {
  331.         $new .= "\$$id";
  332.         $new .= '->' if /^[\[\{]/;
  333.         } elsif ($id eq 'defined') {
  334.         $new .= 'defined';
  335.         } elsif (/^\(/) {
  336.         s/^\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/i;    # cheat
  337.         $new .= " &$id";
  338.         } elsif ($isatype{$id}) {
  339.         if ($new =~ /{\s*$/) {
  340.             $new .= "'$id'";
  341.         } elsif ($new =~ /\(\s*$/ && /^[\s*]*\)/) {
  342.             $new =~ s/\(\s*$//;
  343.             s/^[\s*]*\)//;
  344.         } else {
  345.             $new .= q(').$id.q(');
  346.         }
  347.         } else {
  348.         if ($inif && $new !~ /defined\s*\($/) {
  349.             $new .= '(defined(&' . $id . ') ? &' . $id . ' : 0)';
  350.         } elsif (/^\[/) {
  351.             $new .= " \$$id";
  352.         } else {
  353.             $new .= ' &' . $id;
  354.         }
  355.         }
  356.         next;
  357.     };
  358.     s/^(.)// && do { if ($1 ne '#') { $new .= $1; } next;};
  359.     }
  360. }
  361.  
  362.  
  363. # Handle recursive subdirectories without getting a grotesquely big stack.
  364. # Could this be implemented using File::Find?
  365. sub next_file
  366. {
  367.     my $file;
  368.  
  369.     while (@ARGV) {
  370.         $file = shift @ARGV;
  371.  
  372.         if ($file eq '-' or -f $file or -l $file) {
  373.             return $file;
  374.         } elsif (-d $file) {
  375.             if ($opt_r) {
  376.                 expand_glob($file);
  377.             } else {
  378.                 print STDERR "Skipping directory `$file'\n";
  379.             }
  380.         } elsif ($opt_a) {
  381.             return $file;
  382.         } else {
  383.             print STDERR "Skipping `$file':  not a file or directory\n";
  384.         }
  385.     }
  386.  
  387.     return undef;
  388. }
  389.  
  390.  
  391. # Put all the files in $directory into @ARGV for processing.
  392. sub expand_glob
  393. {
  394.     my ($directory)  = @_;
  395.  
  396.     $directory =~ s:/$::;
  397.  
  398.     opendir DIR, $directory;
  399.         foreach (readdir DIR) {
  400.             next if ($_ eq '.' or $_ eq '..');
  401.  
  402.             # expand_glob() is going to be called until $ARGV[0] isn't a
  403.             # directory; so push directories, and unshift everything else.
  404.             if (-d "$directory/$_") { push    @ARGV, "$directory/$_" }
  405.             else                    { unshift @ARGV, "$directory/$_" }
  406.         }
  407.     closedir DIR;
  408. }
  409.  
  410.  
  411. # Given $file, a symbolic link to a directory in the C include directory,
  412. # make an equivalent symbolic link in $Dest_dir, if we can figure out how.
  413. # Otherwise, just duplicate the file or directory.
  414. sub link_if_possible
  415. {
  416.     my ($dirlink)  = @_;
  417.     my $target  = eval 'readlink($dirlink)';
  418.  
  419.     if ($target =~ m:^\.\./: or $target =~ m:^/:) {
  420.         # The target of a parent or absolute link could leave the $Dest_dir
  421.         # hierarchy, so let's put all of the contents of $dirlink (actually,
  422.         # the contents of $target) into @ARGV; as a side effect down the
  423.         # line, $dirlink will get created as an _actual_ directory.
  424.         expand_glob($dirlink);
  425.     } else {
  426.         if (-l "$Dest_dir/$dirlink") {
  427.             unlink "$Dest_dir/$dirlink" or
  428.                 print STDERR "Could not remove link $Dest_dir/$dirlink:  $!\n";
  429.         }
  430.  
  431.         if (eval 'symlink($target, "$Dest_dir/$dirlink")') {
  432.             print "Linking $target -> $Dest_dir/$dirlink\n";
  433.  
  434.             # Make sure that the link _links_ to something:
  435.             if (! -e "$Dest_dir/$target") {
  436.                 mkpath("$Dest_dir/$target", 0755) or
  437.                     print STDERR "Could not create $Dest_dir/$target/\n";
  438.             }
  439.         } else {
  440.             print STDERR "Could not symlink $target -> $Dest_dir/$dirlink:  $!\n";
  441.         }
  442.     }
  443. }
  444.  
  445.  
  446. # Push all #included files in $file onto our stack, except for STDIN
  447. # and files we've already processed.
  448. sub queue_includes_from
  449. {
  450.     my ($file)    = @_;
  451.     my $line;
  452.  
  453.     return if ($file eq "-");
  454.  
  455.     open HEADER, $file or return;
  456.         while (defined($line = <HEADER>)) {
  457.             while (/\\$/) { # Handle continuation lines
  458.                 chop $line;
  459.                 $line .= <HEADER>;
  460.             }
  461.  
  462.             if ($line =~ /^#\s*include\s+<(.*?)>/) {
  463.                 push(@ARGV, $1) unless $is_converted{$1};
  464.             }
  465.         }
  466.     close HEADER;
  467. }
  468.  
  469.  
  470. # Determine include directories; $Config{usrinc} should be enough for (all
  471. # non-GCC?) C compilers, but gcc uses an additional include directory.
  472. sub inc_dirs
  473. {
  474.     my $from_gcc    = `$Config{cc} -v 2>&1`;
  475.     $from_gcc       =~ s:^Reading specs from (.*?)/specs\b.*:$1/include:s;
  476.  
  477.     length($from_gcc) ? ($from_gcc, $Config{usrinc}) : ($Config{usrinc});
  478. }
  479.  
  480.  
  481. 1;
  482.  
  483. ##############################################################################
  484. __END__
  485.  
  486. =head1 NAME
  487.  
  488. h2ph - convert .h C header files to .ph Perl header files
  489.  
  490. =head1 SYNOPSIS
  491.  
  492. B<h2ph [-d destination directory] [-r | -a] [-l] [headerfiles]>
  493.  
  494. =head1 DESCRIPTION
  495.  
  496. I<h2ph>
  497. converts any C header files specified to the corresponding Perl header file
  498. format.
  499. It is most easily run while in /usr/include:
  500.  
  501.     cd /usr/include; h2ph * sys/*
  502.  
  503. or
  504.  
  505.     cd /usr/include; h2ph -r -l .
  506.  
  507. The output files are placed in the hierarchy rooted at Perl's
  508. architecture dependent library directory.  You can specify a different
  509. hierarchy with a B<-d> switch.
  510.  
  511. If run with no arguments, filters standard input to standard output.
  512.  
  513. =head1 OPTIONS
  514.  
  515. =over 4
  516.  
  517. =item -d destination_dir
  518.  
  519. Put the resulting B<.ph> files beneath B<destination_dir>, instead of
  520. beneath the default Perl library location (C<$Config{'installsitsearch'}>).
  521.  
  522. =item -r
  523.  
  524. Run recursively; if any of B<headerfiles> are directories, then run I<h2ph>
  525. on all files in those directories (and their subdirectories, etc.).  B<-r>
  526. and B<-a> are mutually exclusive.
  527.  
  528. =item -a
  529.  
  530. Run automagically; convert B<headerfiles>, as well as any B<.h> files
  531. which they include.  This option will search for B<.h> files in all
  532. directories which your C compiler ordinarily uses.  B<-a> and B<-r> are
  533. mutually exclusive.
  534.  
  535. =item -l
  536.  
  537. Symbolic links will be replicated in the destination directory.  If B<-l>
  538. is not specified, then links are skipped over.
  539.  
  540. =item -h
  541.  
  542. Put ``hints'' in the .ph files which will help in locating problems with
  543. I<h2ph>.  In those cases when you B<require> a B<.ph> file containing syntax
  544. errors, instead of the cryptic
  545.  
  546.     [ some error condition ] at (eval mmm) line nnn
  547.  
  548. you will see the slightly more helpful
  549.  
  550.     [ some error condition ] at filename.ph line nnn
  551.  
  552. However, the B<.ph> files almost double in size when built using B<-h>.
  553.  
  554. =item -D
  555.  
  556. Include the code from the B<.h> file as a comment in the B<.ph> file.
  557. This is primarily used for debugging I<h2ph>.
  558.  
  559. =back
  560.  
  561. =head1 ENVIRONMENT
  562.  
  563. No environment variables are used.
  564.  
  565. =head1 FILES
  566.  
  567.  /usr/include/*.h
  568.  /usr/include/sys/*.h
  569.  
  570. etc.
  571.  
  572. =head1 AUTHOR
  573.  
  574. Larry Wall
  575.  
  576. =head1 SEE ALSO
  577.  
  578. perl(1)
  579.  
  580. =head1 DIAGNOSTICS
  581.  
  582. The usual warnings if it can't read or write the files involved.
  583.  
  584. =head1 BUGS
  585.  
  586. Doesn't construct the %sizeof array for you.
  587.  
  588. It doesn't handle all C constructs, but it does attempt to isolate
  589. definitions inside evals so that you can get at the definitions
  590. that it can translate.
  591.  
  592. It's only intended as a rough tool.
  593. You may need to dicker with the files produced.
  594.  
  595. =cut
  596.  
  597.